<?php
header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // never, ever cache
$callback = $_REQUEST['callback'];
$more = 1;

$items = array();
query_posts("");
while (have_posts()) :
the_post();
$item = array(
	"title" => get_the_title_rss(),
	"link" => apply_filters('the_permalink_rss', get_permalink()),
	"description" => apply_filters('the_excerpt_rss', get_the_excerpt()));
$items[] = $item;
endwhile;

$arr = array(
'title' => get_bloginfo_rss('name'),
'link' => get_bloginfo_rss('url'),
'description' => get_bloginfo_rss('description'),
'language' => get_option('rss_language'),
'item' => $items);

//echo "".$HTTP_GET_VARS["callback"]."(".json_encode($arr).");";

//start output
if ($callback) {
    header('Content-Type: text/javascript');
    echo $callback . '(' . json_encode($arr) . ');';
} else {
    header('Content-Type: application/json');
    echo json_encode($arr);
}
?>